/**
 * MeetSourceDaoImpl.java
 */
package com.prs.crm.dao.meeting.impl;

import java.io.Serializable;
import java.sql.SQLException;
import java.util.Collection;
import java.util.List;

import org.courser.hibernate.QueryExample;
import org.courser.ui.PaginationSupport;
import org.hibernate.Criteria;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Order;
import org.hibernate.criterion.Restrictions;
import org.springframework.orm.hibernate3.HibernateCallback;

import com.prs.crm.dao.impl.BaseDaoImpl;
import com.prs.crm.dao.meeting.MeetSourceDao;
import com.prs.crm.domain.hr.Dept;
import com.prs.crm.domain.meeting.MeetRoom;
import com.prs.crm.domain.meeting.MeetSource;

/**
 * @author ZhuDongMei
 * @E-mail:1223984339@qq.com
 * @qq:1223984339
 * @version 创建时间：2011-3-16 上午11:12:28 简单说明
 */

public class MeetSourceDaoImpl extends BaseDaoImpl<MeetSource> implements MeetSourceDao {
	@SuppressWarnings("unchecked")
	@Override
	public List<MeetSource> getAllMeetSources() {
		// TODO Auto-generated method stub
		return (List<MeetSource>)this.getHibernateTemplate().execute(new HibernateCallback() {

			@Override
			public Object doInHibernate(Session session)
			throws HibernateException, SQLException {
		// TODO Auto-generated method stub
		Criteria criteria = session.createCriteria(MeetSource.class)
		.add(Restrictions.isNull("parent"));
		criteria.addOrder(Order.asc("id"));
		return criteria.list();
	}

		});
	}

	@SuppressWarnings("unchecked")
	@Override
	public Collection<MeetSource> getRootMeetSources() {
		return (Collection<MeetSource>)this.getHibernateTemplate().execute(
				new HibernateCallback()
				{
					public Object doInHibernate(Session session) throws HibernateException {
			        	Criteria criteria = session.createCriteria(MeetSource.class);
			        	criteria.add(Restrictions.isNull("parent"));
			        	criteria.addOrder(Order.asc("id"));
			        	return criteria.list();
			        }   
				}
		);
	}

}
